package day20;

import java.util.*;

public class Homework6 {
    public static void main(String[] args) {
        int nums[]={1,2,3,4,5,6,3,2,5,2};
        int sum=0;
        Map<Integer,Integer> map=new HashMap<>();
        for (int i=0;i<nums.length;i++){
//            for (int j=0;j<nums.length;j++){
//                if (nums[i]==nums[j]){
//                    sum++;
//                    map.put(nums[i],sum);
//                }
//            }
//            sum=0;

        }
        System.out.println(map);
    }
}


abstract class  Animal{
    public abstract void makeSound();
}
class Dog extends Animal{
    public void makeSound() {
        System.out.println("狗叫声：汪汪汪！");
    }
}
class Cat extends Animal{
    public void makeSound() {
        System.out.println("猫叫声：喵喵喵！");
    }
}
class Cow extends Animal{
    public void makeSound() {
        System.out.println("牛叫声：哞哞哞！");
    }
}
class Zoo{
    private List<Animal> list;
    public Zoo() {
        list=new ArrayList<>();
    }
    public void addAnimal(Animal animal){
         list.add(animal);
         System.out.println(animal+"添加成功！");
    }

    public void showAnimalSounds(){
//         for (Animal animal:list){
//              animal.makeSound();
//         }
        list.stream().forEach(a->a.makeSound());
    }
    public static void main(String[] args) {
         Zoo zoo=new Zoo();
         zoo.addAnimal(new Dog());
         zoo.addAnimal(new Cat());
         zoo.addAnimal(new Cow());
         zoo.showAnimalSounds();
    }
}


class Judgement{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入一个字符串：");
        String str=sc.next();
        char[] ch=str.toCharArray();
        int sum=ch.length-1;
        int count=0;
        for (int i=0;i<ch.length/2;i++){
            if (ch[i]==ch[sum]){
                sum--;
                count++;
            }
        }
        if (count==ch.length/2){
            System.out.println(str+"字符串是回文字符串！");
        }else {
            System.out.println(str+"字符串不是回文字符串！");
        }
    }
}

class CountNumber{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入一个字符串:");
        String str=sc.next();
        char ch[]=str.toCharArray();
        StringBuilder strs= new StringBuilder();
        int sum=1;
        for (int i=0;i<ch.length-1;i++){
            if (ch[i]!=ch[i+1]){
                strs.append(ch[i]).append(sum);
                sum=1;
            }else {
                sum++;
                if ((i-1+sum)==ch.length){
                    strs.append(ch[i]).append(sum);
                }
            }
        }
        if (strs.length()<ch.length){
            System.out.print(strs);
        }else {
            System.out.println(str);
        }

    }
}